feat(shadcn): add className prop support to all components#216
Open
nil957 wants to merge 1 commit intovercel-labs:mainfrom
Open
feat(shadcn): add className prop support to all components#216nil957 wants to merge 1 commit intovercel-labs:mainfrom
nil957 wants to merge 1 commit intovercel-labs:mainfrom
Conversation
Addresses vercel-labs#145 Adds optional `className` prop to all 36+ shadcn components for custom styling. The prop is forwarded to the root element via cn(), matching how shadcn/ui itself works. Changes: - Added `className: z.string().nullable()` to all component schemas - Forward className to root element: cn(existingClasses, props.className) - Enables fine-tuning without rewriting entire components Example: ```json { "type": "Card", "props": { "title": "Stats", "className": "gap-1" } } ``` This overrides the default gap-3 on CardContent.
Contributor
|
Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #145
Adds optional
classNameprop to all shadcn components for custom styling, matching how shadcn/ui itself works.Changes
Catalog (
packages/shadcn/src/catalog.ts)className: z.string().nullable()to all 36+ component schemasComponents (
packages/shadcn/src/components.tsx)classNameto root elements viacn(existingClasses, props.className)Example
Before
{ "type": "Card", "props": { "title": "Stats" } }→ Forced to use
gap-3on CardContent, no override possibleAfter
{ "type": "Card", "props": { "title": "Stats", "className": "gap-1" } }→ Can override to
gap-1for compact stat cardsUse Cases
hidden md:block)Checklist